import ipcTips from './tips.vue'

let Tips = {};

//只有定义了install方法，才能使用Vue.use 进行引用
Tips.install = function (Vue,options){

	let _options = {
		delay:300000
	}

	//参数覆盖
	for(let key in options){
		_options[key] = options[key]
	}


	const TipsController = Vue.extend(ipcTips)
	let instance = new TipsController();
	instance.$mount(document.createElement('div'));
	document.body.appendChild(instance.$el);

	let timer;

	const tips_main = {
		show:function(msg,opt){
			//参数覆盖
			let cb = '';

			if(typeof opt === 'object' && opt !== null){
				for(let key in opt){
					_options[key] = opt[key]
				}
			}else if(typeof opt === 'function'){
				cb = opt;
			}

			instance.msg = msg;
			instance.showFlag = true;

			setTimeout(() => {
				instance.showFlag = false;
			},_options.delay)
		}
	} 

	//将方法挂载全局
    Vue.prototype.$ipcTips = tips_main;
}

/*if(typeof window !== 'undefined' && window.Vue){
	window.Vue.use(Tips)
}*/

export default Tips;